<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
  components: {
    SelectDataGoods: async () =>
      Vue.extend(await Vue.prototype.$vFN.Components.Base.SelectDataGoods()),
  },
  data() {
    return {
      appWindow: window,
      form: {},

      goodsIds: [],

      load: true,
    };
  },
  methods: {
    async getData() {
      this.goodsIds = [];
      let res = await this.$vFN.Http.post(
        {
          url: "store/recommend/detail",
        },
        window
      );
      if (res._ok) {
        res.data.list.forEach(item => {
          this.goodsIds.push(item.item.id);
        });
        this.load = false;
      }
    },
    // 提交
    async sum() {
      this.load = true;
      let res = await this.$vFN.Http.post(
        {
          url: "store/recommend/edit",
          data: {
            ids: this.goodsIds,
          },
        },
        window
      );
      if (res._ok) {
        this.$vFN.Tools.messageSuccess("操作成功");
        this.getData();
      }
    },

    // 初始化
    async init() {
      this.getData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>